<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="/public/stylesheets/style.css">
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script src="/public/javascripts/layer/mobile/layer.js"></script>
</head>
<body>
    用户名:<input class="user" type="text" placeholder="用户名:"><br>
    密码:<input class="pwd" type="text" placeholder="密码:"><br>
    tel:<input class="tel" type="text" placeholder="tel:"><br>
    男<input type="checkbox" name="sex" value="1">
    女<input type="checkbox" name="sex" value="0">
    <button id="login">登陆</button>
</body>
<script>
    $('#login').click(()=>{
            let user = $('.user').val()
            let pwd = $('.pwd').val()
            let tel = $('.tel').val()
            let sex = $('[name="sex"]').val()
            if(!tel.match(/[0-9]+/)){ alert("tel no number"); return false}
            $.ajax({
                type: "get",
                url: "/users/reg/reg",
                data: {
                    user,
                    tel,
                    pwd,
                    sex
                },
                dataType: "jsonp",
                success: function (res) {
                    console.log(res)
                    layer.open({
                        content:  res.msg,
                        skin:'msg',
                        time: 2,
                    })
                    // if(res.code){
                    //    window.location.href='/my'
                    // }
                }
            });
    }) 
</script>
</html>